package com.itheima.service.rabbitMQ.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 设置队列和交换机，并设置绑定关系
 */
@Configuration
public class RabbitMQConfig {
    //创建一个队列
    @Bean
    public Queue directQueue(){
        return new Queue("directQueue");
    }

    //创建一个直连交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("directExchange");
    }

    //将交换机和队列绑定
    @Bean
    public Binding bindingDirect(){
        return BindingBuilder.bind(directQueue()).to(directExchange()).with("direct");
    }
}
